﻿using System;
using SilverChart.Core.Service;

namespace SilverChart.Core.Configuration.Converter {
    [ServiceProvider(LayzeCreation = true, ServiceName = "Default DateTime configuration converter", Singleton = true)]
    public class DateTimeConverter : ConfigurationConverter<DateTime> {
        #region ConfigurationConverter<DateTime> Members
        public bool Convert(String itemValue, out DateTime value) {
            if (itemValue == null || !DateTime.TryParse(itemValue, out value)) {
                value = DateTime.Now;
                return false;
            }
            return true;
        }
        #endregion
    }
}
